package forum.communication;

import forum.server.controller.ForumFacadeInt;
import forum.server.exceptions.InvalidSearchRangeException;

public class SearchByContentMessage extends ClientMessage{

	/**
	 * 
	 */
	private static final long serialVersionUID = 3391988955159079138L;

	private String content;
	private int from;
	private int to;
	
	public SearchByContentMessage(String content, int from, int to) {
		this.content = content;
		this.from = from;
		this.to = to;
	}
	@Override
	public ServerResponse doOperation(ForumFacadeInt forum) {
		try {
			return new ServerResponse(forum.searchByContent(content, from, to),true);
		} catch (InvalidSearchRangeException e) {
			return new ServerResponse(e.getMessage(),false);
		}		
	}
}
